<?php
/**
 * Created by PhpStorm.
 * User: liuhong
 * Date: 2019-04-08
 * Time: 15:32
 */

namespace app\api\controller;


use app\common\model\Coach as CoachModel;
use app\common\model\UserTourist;

class Coach extends Base
{

    public function __construct()
    {
        parent::__construct();
    }

    /**
     * 课程列表
     * @return \think\response\Json
     */
    public function coach()
    {
        if (request()->isPost()) {
            $page = input('page', 1);
            $size = input('size', 6);

            $coach = CoachModel::getPage($where, $page, $size, 'ord desc');
            if ($coach) {
                foreach ($coach as $key => $value) {
                    if ($value['type'] == 2) {
                        $coach[$key]['end_time'] = date('H:i:s', $value['end_time']);
                    }
                }
            }
            return returnJson(200, '', $coach);
        }
        return returnJson(202, '暂无记录');
    }

    /**
     * 课程详情
     * @return \think\response\Json
     */
    public function detail()
    {
        if(request()->isPost()){
            $data = input('');
            if($data['id']){
                $coach = CoachModel::getOne(['id'=>$data['id']]);
                if($coach){
                    return returnJson(200,'',$coach);
                }
            }
            return returnJson(202,'教练员不存在');
        }
    }


}